import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Test11 {
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int a = 0;
        int b = 1;
        while (b < N){
            a = a+b;
            if(a>N){
               int tmp = b;
               b = a;
               a = tmp;
                break;
            }
            b = a+b;
        }
        System.out.println(Math.min((N - a), (b - N)));
    }

    public static void main(String[] args) {
        System.out.println(chkParenthesis("(()))", 5));
    }
    public static boolean chkParenthesis(String A, int n) {
        // write code here
        Deque<Character> deque = new LinkedList<>();
        if(n % 2 != 0){
            return false;
        }
        for (int i = 0; i < n; i++) {
           char ch = A.charAt(i);
            if(ch != '(' && ch != ')'){
                return false;
            }

            if (deque.isEmpty()){
                deque.push(ch);
            }else {
                if((deque.peek() == '(' && ch == ')') ||(deque.peek() == ')' && ch == '(')){
                    deque.pop();
                }else {
                    deque.push(ch);
                }
            }
        }
        if (deque.isEmpty()){
            return true;
        }
        return false;
    }
}
